package com.itheima.demo.my_set;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class SetDemo01 {
    /*
     *@Author Apollo
     *@Date 11:10 2021/7/26
     *@Description set遍历练习
     **/
    public static void main(String[] args) {
        Set<String> set = new TreeSet<>();
        set.add("aaa");
        set.add("bbb");
        set.add("ccc");
        set.add("ddd");

        //迭代器遍历
        Iterator<String> iterator = set.iterator();
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }

        System.out.println("--------");

        //增强for遍历
        for (String s : set) {
            System.out.println(s);
        }
    }
}
